/*
 *  Copyright 2019-2020 Zheng Jie
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package me.zhengjie.pojo.sqlServer;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author xinglin
 * @website https://eladmin.vip
 * @description /
 * @date 2024-08-03
 **/
@Entity
@Data
@Table(name = "pp_inventory")
public class PPInventory implements Serializable {

    @Id
    @Column(name = "`id`")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @ApiModelProperty(value = "id")
    private Integer id;

    @Column(name = "`batch`")
    @ApiModelProperty(value = "产品批次号")
    private String batch;

    @Column(name = "`pp`")
    @ApiModelProperty(value = "pp批次号")
    private String pp;

    // 统一使用带反引号的列名定义
    @Column(name = "`pp_batch`")
    @ApiModelProperty(value = "板子批次号")
    private String ppBatch;

    @Column(name = "`pallet_code`")
    @ApiModelProperty(value = "载盘编码")
    private String palletCode;

    @Column(name = "`storage_code`")
    @ApiModelProperty(value = "储位号")
    private String storageCode;

    @Column(name = "`qty`")
    @ApiModelProperty(value = "数量")
    private Integer qty;

    @Column(name = "`in_bound_time`")
    @ApiModelProperty(value = "入库时间")
    private LocalDateTime inBoundTime;

    @Column(name = "`out_bound_time`")
    @ApiModelProperty(value = "出库时间")
    private LocalDateTime outBoundTime;

    @Column(name = "`is_pakage`")
    @ApiModelProperty(value = "是否打包")
    private Integer isPakage;

    @Column(name = "`warning_time`")
    @ApiModelProperty(value = "预警日期")
    private LocalDateTime warningTime;


    @Column(name = "`out_time`")
    @ApiModelProperty(value = "超期日期")
    private LocalDateTime outTime;

    @Column(name = "`pp_pd`")
    @ApiModelProperty(value = "生产日期")
    private LocalDateTime pdTime;


    @Column(name = "`exp_time`")
    @ApiModelProperty(value = "过期日期")
    private LocalDateTime expTime;



    @Column(name = "`date_status`")
    @ApiModelProperty(value = "正常：safe，预警：warning，超期：outTime，过期：exp")
    private String dateStatus;

    @Column(name="`stay_status`")
    @ApiModelProperty(value = "0:在库，1：出库")
    private Integer stayStatus;

    @Column(name="`lock_status`")
    @ApiModelProperty(value = "0:禁用，1：启用")
    private Integer lockStatus;


    //链接表
    // 修正关联映射
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(
            name = "`pp_batch`", // 这里也使用带反引号
            referencedColumnName = "`pp_batch`", // 这里也使用带反引号
            insertable = false,
            updatable = false
    )
    private PPinfoJoin ppInfo;;


    public void copy(PPInventory source) {
        BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
